package com.hzeport.bgs22emduty.config;

import lombok.extern.slf4j.Slf4j;

import java.io.IOException;
import java.net.*;
import java.util.ArrayList;
import java.util.List;

/**
 * @author zhangyangyang
 * @description
 * @date 2023/11/16 16:44
 */
@Slf4j
public class MyProxySelector extends ProxySelector {
    @Override
    public List<Proxy> select(URI uri) {
        List<Proxy> proxies=new ArrayList<>();
        String host=uri.getHost();
        if (host.contains("hb2020.dev-xc.com")) {
             proxies.add(new Proxy(Proxy.Type.HTTP,new InetSocketAddress("10.99.105.119",8080)));
        }
        return proxies;
    }

    @Override
    public void connectFailed(URI uri, SocketAddress sa, IOException ioe) {
        log.error("代理服务器访问失败",ioe);
    }
}
